#pragma once

#include <stdio.h>
typedef struct FastTempResult {
	int using_fast_flag;	// 是否开始进入快速升温逻辑，0：未进入，1：进入
	float shijiwendu;		// 快速升温算法返回的要显示的温度
	int flat_wendingxing;	// 温度稳定性标记，0：不稳定不允许退出，1：稳定可以退出
	float chushiwendu_tb;	// 快速升温标记using_fast_flag=1时，参考的基准温度
	int flag_error;         // 快速升温异常标记，0：无异常，1：快速升温阶段，预测结果计算前异常退出，2：快速升温预测完之后异常退出
	int stage;              // 快速升温各阶段标记。0：未进入升温阶段；1：初始升温阶段；2：迭代阶段；3：升温结束阶段
	float last_tempini_check;
} FastTempResult_t;

class CFastTempHome
{
private:
	float sx = 0, sy = 0, sxy = 0, sxx = 0, ln = 0, guzhang = 0;                   // 最小二乘相关变量
	float lastwendu_hj = 0, lastchafen_hj = -100, chushiwendu_hj = -100, chushichafen1_hj = 0;   // 环境温度相关变量
	float lastwendu_tb = 0, lastchafen_tb = -100, last_chushiwendu_tb = -100, chushiwendu_tb = -100, chushichafen1_tb = 0, chushichafen2_tb = 0;     // 体表温度相关变量
	float maxwendu = 0, maxwencha = 0, buchangxishu = 0, finyucewendu = 0;             // 循环、判断相关变量
	int flag = 0, jishu = 0, jishu0 = 0, jishu1 = 0;
	int flag_stage = 0, flag_error = 0, temple = 0, last_tempini_check = 0;
	float Paras_home[11] = { -0.01444,11.00891,-0.25458,-0.18255,11.11638,-13.24930,-0.50378,0.03876,0.40543,-0.61135,4.89805 };
	float Paras_hosp[11] = { 0.0474, 9.6133, -0.3361, -0.1733, -1.1434, 2.4108, 0.5567, -0.1724, -0.3718, -1.0601, -0.6026 };
public:
	CFastTempHome();
	~CFastTempHome();
	void init();
	float MYLOG(float a);
	float mydaoshu(float a);
	float myexp(float a);
	int Stable(float (*TempBuffPoint)[4], int length, int last);
	float kuaisushengwen(float tibiaowendu, float huanjingwendu, int type_use);  // 第3个参数时病房和家庭的种类标记，1为病房，0为家庭，采用不同的拟合参数
	FastTempResult_t wendu(float tibiaowendu, float huanjingwendu, float (*TempBuffPoint)[4], int length, int last, int type_use);
};

